﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Figure
{
    abstract class Figure
    {
        abstract public bool Check();
        abstract public double GetArea();
    }
    class Triangle:Figure
    {
        private double a, b, c;
        Triangle(double na,double nb,double nc)
        {
            a = na;
            b = nb;
            c = nc;
        }
        public override bool Check()
        {
            if (a <= 0 || b <= 0 || c <= 0) return false;    
            if (a + b <= c) return false;
            if (a + c <= b) return false;
            if (b + c >= a) return false;
            return true;
        }
        public override double GetArea()
        {
            // 海伦公式
            double p = (a + b + c) / 2;
            double area = Math.Sqrt(p * (p - a) * (p - b) * (p - c));
            return area;
        }
    }
    class Rectangle:Figure
    {
        private double length, width;
        Rectangle(double l,double w)
        {
            length = l;
            width = w;
        }
        public override bool Check()
        {
            if (length <= 0 || width <= 0) return false;
            return true;
        }
        public override double GetArea()
        {
            return length * width;
        }
    }
    class Square:Figure
    {
        private double side;
        Square(double s)
        {
            side = s;
        }
        public override bool Check()
        {
            if (side <= 0) return false;
            return true;
        }
        public override double GetArea()
        {
            return side * side;
        }
    }
    public class ReportFigure
    {
        ReportFigure(string type)
        {
            Console.WriteLine("This program cannot create a " + type + "instance");
        }
    }
    class FigureFactory 
    {
        FigureFactory(string type, double a)
        {
            if (type != "Square")
            {
                ReportFigure r = new ReportFigure(type);

            }               
        }
        FigureFactory(string type, int a, int b)
        {

        }
        FigureFactory(string type,int a,int b,int c)
        {

        }        
    }
    class Program
    {
        static void Main(string[] args)
        {
            
        }
    }
}
